package com.kummuna.adapter;

import java.util.ArrayList;
import java.util.HashMap;

import java.util.ArrayList;
import java.util.HashMap;

import com.kummuna.R;
import com.kummuna.ui.DetectShortpath;
import com.kummuna.util.image.ImageLoader;
import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class SuggestListAdapter extends BaseAdapter {

	    private Activity activity;
	    private ArrayList<HashMap<String, String>> data;
	    private static LayoutInflater inflater=null;
	    public ImageLoader imageLoader; 
	    private Context mContext;
	    LayoutInflater mInflater;
	    
	    
	    public SuggestListAdapter(Activity a, ArrayList<HashMap<String,String>> d) {
	        activity = a;
	        data=d;
	        inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	        imageLoader=new ImageLoader(activity.getApplicationContext());
	    }
	    
	    public SuggestListAdapter(Context pContext) {
	        mContext = pContext;
	         //executorService=Executors.newFixedThreadPool(10);
	         mInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	    }

	    
    



@Override
public int getCount() {
	// TODO Auto-generated method stub
	return data.size();
}

@Override
public Object getItem(int position) {
	// TODO Auto-generated method stub
	return position;
}

@Override
public long getItemId(int position) {
	// TODO Auto-generated method stub
	return position;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
	// TODO Auto-generated method stub
	View vi=convertView;
    if(convertView==null)
        vi = inflater.inflate(R.layout.suggestlist_row, null);
    TextView Topic = (TextView)vi.findViewById(R.id.topic); // topic
    TextView Detail = (TextView)vi.findViewById(R.id.detail); // detail
    TextView duration = (TextView)vi.findViewById(R.id.duration); // duration
    ImageView thumb_image=(ImageView)vi.findViewById(R.id.list_image); // thumb image
    
    HashMap<String, String> listuser = new HashMap<String, String>();
    listuser = data.get(position);
    
    Topic.setText(listuser.get(DetectShortpath.TAG_Topic));
    Detail.setText(listuser.get(DetectShortpath.TAG_Detail));
    duration.setText(listuser.get(DetectShortpath.TAG_Distance));
    imageLoader.DisplayImage(listuser.get(DetectShortpath.TAG_Image), thumb_image);
		
	return vi;
}

public void remove(Object item) {
	// TODO Auto-generated method stub
	data.remove(item);
	
}
}
